<template>
  <div>
    <FilterTable ref="table" :columns="columns" :height="300" :params="fetchParams" :dataSource="saleStuffList" :onColumnsChange="columns => (this.columns = columns)"></FilterTable>
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
import { queryRoLabourByRoNO } from '@/api/repair/business/customer/vehicleDetails';
export default {
  name: 'SaleStuff',
  mixins: [dictionary],
  props: ['roNo', 'empty'],
  data() {
    this.dmsFunc = {};
    return {
      columns: this.createTableColumns(),
      fetchParams: { xhrAbort: false },
      saleStuffList: []
    };
  },
  watch: {
    empty(val) {
      if (val) {
        this.changeempty();
      }
    }
  },
  created() {
    this.dmsFunc = { dmsFuncId: 35100010, order: 'asc' };
    this.queryRoLabourByRoNOFun();
  },
  mounted() {
    this.changeempty();
  },
  methods: {
    createTableColumns() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '收费类别',
          dataIndex: 'MANAGE_SORT_NAME',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '收费区分',
          dataIndex: 'CHARGE_PARTITION_NAME',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '仓库代码',
          dataIndex: 'STORAGE_CODE',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '库位代码',
          dataIndex: 'STORAGE_POSITION_CODE',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '备件代码',
          dataIndex: 'PART_NO',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '备件名称',
          dataIndex: 'PART_NAME',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '计量单位',
          dataIndex: 'UNIT_NAME',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '备件销售数量',
          dataIndex: 'PART_QUANTITY',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '备件销售单价',
          dataIndex: 'PART_SALES_PRICE',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '成本价',
          dataIndex: 'PART_COST_PRICE',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '备件销售金额',
          dataIndex: 'PART_SALES_AMOUNT',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '优惠金额',
          dataIndex: 'DISCOUNT_AMOUNT',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '折扣率',
          dataIndex: 'DISCOUNT',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '实收金额',
          dataIndex: 'RECEIVE_AMOUNT',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '是否入账',
          dataIndex: 'IS_FINISHED',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('1278'),
          render: props => {
            return <span>{this.createDictText(props.row.IS_FINISHED, '1278')}</span>;
          }
        }
      ];
    },
    async queryRoLabourByRoNOFun() {
      const res = await queryRoLabourByRoNO(this.dmsFunc, this.roNo);
    },
    // 清空列表
    changeempty() {
      if (this.empty) {
        this.saleStuffList = [];
        this.$emit('changeEmpty', false);
      }
      return;
    }
  }
};
</script>

<style lang="less"></style>
